package com.dj.product.k2faas.entity.function;

import com.dj.product.k2faas.entity.function.config.AbstractFunctionConfig;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import jakarta.persistence.*;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.annotations.Comment;

/**
 * Created by 丁建 on 2025/9/23 10:32
 *
 * @author 丁建
 */
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@Accessors(chain = true)
@Table
@Entity
public class Function {

    public enum FunctionType {
        HTTP, 定时任务
    }

    public enum FunctionStatus {
        禁用, 未运行, 运行中
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    @Comment("挂载到云的ID")
    private Long cloudId;

    @Comment("方法名")
    private String name;

    @Comment("主法备注")
    @Column(columnDefinition = "TEXT")
    private String description;

    @Comment("方法内容")
    @Column(columnDefinition = "TEXT")
    private String content;

    @Comment("方法调用类型")
    @Enumerated(EnumType.STRING)
    private FunctionType functionType = FunctionType.HTTP;

    @Comment("方法配置")
    @Column(columnDefinition = "TEXT")
    private AbstractFunctionConfig config;

    @Comment("方法状态")
    @Enumerated(EnumType.STRING)
    private FunctionStatus status = FunctionStatus.未运行;

}
